﻿using System;
using System.ComponentModel;
using System.Web.Mvc;
using HMIS.FrameWork;
using HMIS.FrameWork.Cache;
using HMIS.Infrastructure.Facade.Authority;
using HMIS.MVC.CommonSupport;
using HMIS.MVC.ViewModel;
using HMIS.Infrastructure.Facade;

namespace HMIS.MVC.Controllers
{
	public partial class MainController : BaseController
	{
		private readonly IAuthorityFacade AuthorityFacade;
		private readonly ICache Cache;
		private readonly IInfraMxsqFacade InfraMxsqFacade;
		public MainController(IAuthorityFacade AuthorityFacade, ICache Cache, IInfraMxsqFacade InfraMxsqFacade)
		{
			this.AuthorityFacade = AuthorityFacade;
			this.Cache = Cache;
			this.InfraMxsqFacade = InfraMxsqFacade;
		}

		[ExtResult]
		[Description("获取一个流水号")]
		public ActionResult GetNewID()
		{
			string sqnodt = Request["sqnodt"] == null ? System.DateTime.Now.ToString("yyyyMMdd") : Request["sqnodt"].Trim();
			string sqnodp = Request["sqnodp"] == null ? "0000" : Request["sqnodp"].Trim();
			string newId = InfraMxsqFacade.GetNewId(Request["sqnocd"], sqnodp, sqnodt);
			return this.JsonFormat(new ExtResult { success = true, id = newId });
		}
	}
}
